from datetime import datetime
from typing import Optional, List

from pydantic import BaseModel, EmailStr, PrivateAttr, root_validator

from app.common.generic import SchemaCreate, SchemaUpdate
from app.schemas.base_model import OrmBaseModel


class UserBase(OrmBaseModel):
    id: Optional[int]
    account: Optional[str]
    realName: Optional[str]
    password: Optional[str]
    avatar: Optional[str]
    state: Optional[str]
    createdDate: Optional[datetime]
    updatedDate: Optional[datetime]


class UserLogin(BaseModel):
    username: str
    password: str


class UserInfo(UserBase):
    token: Optional[str]


class UserCreate(UserBase, SchemaCreate):
    pass


class UserUpdate(UserBase, SchemaUpdate):
    pass


class UserInDBBase(UserBase):
    id: Optional[int] = None

    class Config:
        orm_mode = True


# Additional properties to return via API
class User(UserInDBBase):
    pass


# Additional properties stored in DB
class UserInDB(UserInDBBase):
    password: str
